<div class="b-pagename">
	<h1>
		<?php 
		switch ($order) :
			case 'latest': echo 'Latest added'; break;
			case 'random': echo 'Random gifts'; break;
		endswitch;
		?>
	</h1>
</div>

<div class="p-list">
	<?php if ($products['pages'] > 1) : ?>
	<div class="paging">
		<ul>
			<?php for ($i = 0; $i < $products['pages']; $i++) : ?>
			<li>
				<a href="<?=Application::url()?>products/viewall/<?=$order?>/<?=$i?>" 
					class="<?=($products['page'] == $i) ? 'active' : ''?>" 
					title="Page <?=$i + 1?>"></a>
			</li>
			<?php endfor ?>
		</ul>
	</div>
	<?php endif ?>
	<div class="list">
		<ul>
			<?php foreach ($products['data'] as $product) : ?>
			<li>
				<div class="image">
					<a href="<?=Application::url()?>products/view/<?=$product['id']?>">
						<img src="<?=Application::resources()?>storage/products/<?=$product['id']?>/3-<?=$product['image_name']?>" />
					</a>
				</div>
				<div class="name">
					<a href="<?=Application::url()?>products/view/<?=$product['id']?>">
						<?=(strlen($product['name']) > 19)
							? substr($product['name'], 0, 16) . ' ...'
							: $product['name'] ?>
					</a>
				</div>
				<div class="state <?=$product['state']?>"><?=$product['state']?></div>
				<div class="comment">
					<?=(strlen($product['comment']) > 46)
						? substr($product['comment'], 0, 42) . ' ...'
						: $product['comment'] ?>
				</div>
			</li>
			<?php endforeach; ?>
		</ul>
		<div style="clear: both"></div>
	</div>
	<?php if ($products['pages'] > 1) : ?>
	<div class="paging">
		<ul>
			<?php for ($i = 0; $i < $products['pages']; $i++) : ?>
			<li>
				<a href="<?=Application::url()?>products/viewall/<?=$order?>/<?=$i?>" 
					class="<?=($products['page'] == $i) ? 'active' : ''?>" 
					title="Page <?=$i + 1?>"></a>
			</li>
			<?php endfor ?>
		</ul>
	</div>
	<?php endif ?>
</div>